#include <bits/stdc++.h>
using namespace std;

// #define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 100000;

int a[N + 5], mu[N + 5], cnt[N + 5];

vector<int> fac[N + 5];
bool vis[N + 5];

int coprime(int x)
{
	int res = 0;
	for (int y : fac[x])
	{
		res += mu[y] * cnt[y];
	}
	return res;
}

void update(int x, int a)
{
	for (int y : fac[x])
		cnt[y] += a;
}

int main(int argc, char const *argv[])
{
	for (int i = 1; i <= N; ++i)
	{
		for (int j = i; j <= N; j += i)
			fac[j].push_back(i);
		if (i == 1)
			mu[i] = 1;
		else if (i / fac[i][1] % fac[i][1] == 0)
			mu[i] = 0;
		else
			mu[i] = -mu[i / fac[i][1]];
	}

	for (int i = 1; i <= 20; ++i)
		dbg(i, mu[i]);
	int n;
	scanf("%d", &n);
	LL ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int x;
		scanf("%d", &x);
		ans = max(ans, (LL)x);
		vis[x] = 1;
	}
	for (int g = 1; g <= N; ++g)
	{
		static int st[N], top;
		top = 0;
		for (int i = N / g; i > 0; --i)
		{
			if (!vis[i * g])
				continue;
			int c = coprime(i);
			while (c)
			{
				if (__gcd(i, st[top - 1]) == 1)
				{
					ans = max(ans, 1ll * st[top - 1] * i * g);
					--c;
				}
				update(st[--top], -1);
			}
			update(i, 1);
			st[top++] = i;
		}
		while (top)
		{
			update(st[--top], -1);
		}
	}
	printf("%lld\n", ans);
	return 0;
}